

import ttkbootstrap as ttk
from ttkbootstrap.constants import *
from functools import partial
from multiprocessing import Process, Queue

# 导入watchdog模块
import os
import time
from pathlib import Path
import sys
import subprocess

import threading

sys.path.append(str(Path(__file__).parent)) 
import Sequence.main


dataGrid = None


class CustomTable(ttk.Frame):
    
    groupArray = ["1","2"]

    data = []

    _table_listen = None

    dataGrid = None

    def __init__(self, master,table_listen = None):
        print("start CustomTable")
        super().__init__(master)
        
        self.dataGrid = dataGrid
        
        self.create_ui()


    def create_ui(self):

        dataFrame = self
        dataFrame.pack(side=TOP,fill=BOTH, expand=True)
   
        self.dataGrid = ttk.Treeview(master=self,height=10,columns=("num","testName","subTestName","subSubTestName","upperLimit","value","lowerLimit","status","failureMessage","time"),\
            show="headings")
     
        self.dataGrid.pack(fill=BOTH, expand=True)
    
        self.dataGrid.column("num",width=1,anchor="center")
        self.dataGrid.column("testName",width=80,anchor="center")
        self.dataGrid.column("subTestName",width=80,anchor="center", stretch=NO)
        self.dataGrid.column("subSubTestName",width=80,anchor="center", stretch=NO)
        self.dataGrid.column("upperLimit",width=10,anchor="center")
        self.dataGrid.column("value",width=10,anchor="center")
        self.dataGrid.column("lowerLimit",width=7,anchor="center")
        self.dataGrid.column("status",width=7,anchor="center")
        self.dataGrid.column("failureMessage",width=20,anchor="center")
        self.dataGrid.column("time",width=7,anchor="center")
    
        self.dataGrid.heading("num", text="序号")
        self.dataGrid.heading("testName", text="测试项")
        self.dataGrid.heading("subTestName", text="测试名称")
        self.dataGrid.heading("subSubTestName", text="子测试名称")
        self.dataGrid.heading("upperLimit", text="上限")
        self.dataGrid.heading("value", text="值")
        self.dataGrid.heading("lowerLimit", text="下限")
        self.dataGrid.heading("status", text="状态")
        self.dataGrid.heading("failureMessage", text="错误信息")
        self.dataGrid.heading("time", text="时间")


if __name__ == "__main__":
    app = ttk.Window(
        title = "Demo",
        themename="cosmo",
    )
    CustomTable(app)
    app.mainloop()

    table  = CustomTable()
    
